package tedu.study.day04;

import java.util.Scanner;

public class Day04Expand {
    public static void main(String[] args) {
        //创建一个扫描仪
        Scanner scan = new Scanner(System.in);
        //method1(scan);
        //getDays(scan);

        System.out.println("1~100的和为"+sum());
    }
    //if else if
    public static void method1(Scanner scan){
        System.out.println("请输入一个整数：");
        int num = scan.nextInt();
        if(num>0){
            System.out.println("判定结果为：+");
        }else if(num<0){
            System.out.println("判定结果为：-");
        }else{
            System.out.println("判定结果为：0");
        }
    }

    public static void getDays(Scanner scan){
        System.out.println("请输入一个年份：");
        int year = scan.nextInt();
        System.out.println("请输入一个月份：");
        int month = scan.nextInt();

        int days = 0;

        switch(month){
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                days = 31;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                days = 30;
                break;
            case 2:
                if((year%4==0 && year%100!=0)||year%400==0){
                    days = 29;
                }else{
                    days = 28;
                }
        }
        System.out.println(year+"年"+month+"月，有"+days+"天");
    }

    public static int sum(){
        int i = 1;
        int sum = 0;//和
        while(i<=100){
            sum = sum + i;
            i++;
        }
        return sum;
    }
}
